package com.proxy;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * User: yuanjianpeng
 * Date: 2019/1/12
 * Project: webServiceServerTest
 * Version: 1.0
 * Description: 转换基类
 */
public abstract class Converter<T, E> {

    public abstract T convertEtoT(E src);

    public abstract E convertTtoE(T src);

    public List<T> convertListEtoT(List<E> eList){
        if(null == eList || eList.isEmpty()){
            return new ArrayList<>();
        }
        List<T> tList = new ArrayList<>();
        for(E element: eList){
            if(null != element){
                tList.add((T)convertEtoT(element));
            }
        }
        return tList;
    }

    public List<E> convertListTtoE(List<T> tList){
        if(null == tList || tList.isEmpty()){
            return new ArrayList<>();
        }
        List<E> eList = new ArrayList<>();
        for(T element: tList){
            if(null != element){
                eList.add((E)convertTtoE(element));
            }
        }
        return eList;
    }
}
